package com.int_tech.utils.poi;/**
 * Created by Administrator on 2017/12/6.
 */

import com.int_tech.car.dao.CityDao;
import com.int_tech.car.entity.City;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 车牌号转换
 *
 * @author dmy
 * @create 2017-12-06 10:31
 **/
@Service
public class CarMap {

    public HashMap<String, String> carMap(List<City> list) {
        HashMap<String, String> map = new HashMap<>();
        for (City city : list) {
            map.put(city.getCityNumber(), city.getCity());
        }
        return map;
    }

    public static String getKey(HashMap<String, String> map, String value) {
        String key = null;
        //Map,HashMap并没有实现Iteratable接口.不能用于增强for循环.
        for (String getKey : map.keySet()) {
            if (map.get(getKey).equals(value)) {
                key = getKey;
            }
        }
        return key;
        //这个key肯定是最后一个满足该条件的key.
    }
}
